const state = {
	browsingHistory: [],
	articleCache: []
}

const mutations = {
	addBrowsingHistory(state, obj) {
		// 添加一条记录 重复就不添加了
		let flag = true
		state.browsingHistory.forEach((item, index) => {
			if (item.pk === obj.pk) {
				flag = false
			}
		})

		if (flag) {
			state.browsingHistory.push(obj)
		}

	},
	removeOnerBrowsingHistory(state, pk) {
		state.browsingHistory.forEach((item, index) => {
			if (item.pk === pk) {
				state.browsingHistory.splice(index, 1)
				return;
			}
		})
	},
	removeAllBrowsingHistory(state) {
		state.browsingHistory = []
	},
	getBrowsingHistory(state, pk) {
		state.browsingHistory.forEach((item, index) => {
			if (item.pk === pk) {
				return item;
			}
		})

	}
}
export default {
	namespaced: true,
	state,
	mutations,
	actions: {},
	getters: {}
}
